package com.cdn.allmobilestore.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cdn.allmobilestore.R;
import com.cdn.allmobilestore.activity.CategoryAppActivity;
import com.cdn.allmobilestore.activity.LocalAppActivity;
import com.cdn.allmobilestore.activity.PromotionActivity;
import com.cdn.allmobilestore.activity.TutorialActivity;
import com.cdn.allmobilestore.ulti.LocalAppManager;


public class MoreFragment extends BaseFragment
{
	
	
	/**Phong
	 * 
	 */
	public MoreFragment() {
		super();
		// TODO Auto-generated constructor stub
	}

	/* (non-Javadoc)
	 * @see android.support.v4.app.Fragment#onActivityCreated(android.os.Bundle)
	 */
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);
	}

	/* (non-Javadoc)
	 * @see android.support.v4.app.Fragment#onCreate(android.os.Bundle)
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		//
		
	}

	/* (non-Javadoc)
	 * @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
	 */
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {		
		View view = inflater.inflate(R.layout.fragment_more, container, false);
		int totalLocalApps = LocalAppManager.getManager().getCount();
		
		TextView installed_title =(TextView) view.findViewById(R.id.installed_title);
		RelativeLayout installapp_area = (RelativeLayout)view.findViewById(R.id.localapp_area);
		RelativeLayout promotion_area = (RelativeLayout)view.findViewById(R.id.promotion_area);
		RelativeLayout tutorial_area = (RelativeLayout)view.findViewById(R.id.tutorial_area);
		
		if(totalLocalApps > 0)
		{
			installapp_area.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					  Intent intent = new Intent(MoreFragment.this.getActivity(),LocalAppActivity.class);
					  MoreFragment.this.getActivity().startActivity(intent);
					  MoreFragment.this.getActivity().overridePendingTransition(R.anim.slide_in_right, R.anim.disappear);
					
				}
			});
		}
		
		promotion_area.setOnClickListener(new View.OnClickListener() {			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(MoreFragment.this.getActivity(),PromotionActivity.class);
				MoreFragment.this.getActivity().startActivity(intent);
				MoreFragment.this.getActivity().overridePendingTransition(R.anim.slide_in_right, R.anim.disappear);
				
			}
		});
		
		tutorial_area.setOnClickListener(new View.OnClickListener() {			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(MoreFragment.this.getActivity(),TutorialActivity.class);
				intent.putExtra("tutorial_area", 1);
				MoreFragment.this.getActivity().startActivity(intent);
				MoreFragment.this.getActivity().overridePendingTransition(R.anim.slide_in_right, R.anim.disappear);
				
			}
		});
		
		installed_title.setText(MoreFragment.this.getString(R.string.localapp_installed_app,String.valueOf(totalLocalApps) ));
		
		return view;
	}

	
	 
	
}
